package com.miracle.myfav.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.miracle.myfav.base.DBPool;

/**
 * Servlet implementation class ReceiveSite
 */
public class ReceiveSite extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();

		String site = request.getParameter("site");
		String title = request.getParameter("title");
		String cst = request.getParameter("cst");
		System.out.println(title);
		String title1 = new String(title.getBytes("ISO-8859-1"), "UTF-8");

		System.out.println("site:" + site);
		System.out.println("title:" + title1);
		System.out.println("cst:" + cst);
		try {
			String sql = "insert into site(surl,sdesc,sname)values('" + site + "','" + cst + "','" + title1 + "');";
			System.out.println(sql);
			out.print(DBPool.commonExe(sql));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		out.close();
	}
}
